package 剑指offer;

public class 旋转数组的最小数字 {
    ///这是一道二分查找的题
    public int minNumberInRotateArray(int[] array){
        if (array.length == 0) return 0;
        int first = 0;
        int last = array.length-1;
        while (first<last){
            if (array[first] < array[last]){
             return array[first];
            }
            int mid = first + ((last - first)/2);
            if (array[mid] > array[last]){
                first = mid + 1;
            }
            else if (array[mid] < array[last]){
              last = mid;

            }else {
              --last;
            }
        }
             return array[first];
    }
}
